package config

import (
	"fmt"
	"github.com/tietang/props/ini"
	"github.com/tietang/props/kvs"
	"demo_system/core"
)

type IniConfig interface {
	GetValue(string) interface{}
}

type BaseMethod struct {
}

func (b BaseMethod) GetValue(key string) interface{} {
	return ""
}



type MysqlConfig struct {
	BaseMethod
	Username string
	Password string
	Host     string
	Port     string
	Db       string
}



type EnvConfig struct {
	BaseMethod
	Env string
}


func NewConfig(config IniConfig, key string) IniConfig {
	file := core.ROOT_PATH + "/config/config.ini"
	configSource := ini.NewIniFileConfigSource(file)
	err := kvs.Unmarshal(configSource, config, key)
	if err != nil {
		fmt.Println("读取配置文件失败")
	}
	return config
}
